package com.manong.mapper;

import com.manong.domain.GoodsWarehouse;
import java.util.List;

import com.manong.domain.StockDeductDTO;
import org.apache.ibatis.annotations.Param;

public interface GoodsWarehouseMapper {
    int deleteByPrimaryKey(@Param("warehouse_id") Integer warehouse_id, @Param("product_id") Long product_id);

    int insert(GoodsWarehouse record);

    GoodsWarehouse selectByPrimaryKey(@Param("warehouse_id") Integer warehouse_id, @Param("product_id") Long product_id);

    List<GoodsWarehouse> selectAll();

    int updateByPrimaryKey(GoodsWarehouse record);

    void batchInsertOrUpdate(List<GoodsWarehouse> operations);

    Integer selectStockQuantity(@Param("warehouseId") Integer warehouseId,
                                @Param("productId") Long productId);

    // 批量扣除库存
    int batchDeductStock(@Param("warehouseId") Integer warehouseId,
                         @Param("items") List<StockDeductDTO> items);

    void batchUpdateQuantity(List<GoodsWarehouse> updates);

    // 查询当前库存
    Integer getStockQuantity(@Param("warehouseId") Integer warehouseId,
                             @Param("productId") Long productId);
    void updateQuantity(
            @Param("warehouseId") Integer warehouseId,
            @Param("productId") Long productId,
            @Param("quantity") Integer quantity,
            @Param("batchNo") String batchNo
    );
}